defmodule ResistorColor do
  @moduledoc false

  @name_colors  [
      "black",
      "brown",
      "red",
      "orange",
      "yellow",
      "green",
      "blue",
      "violet",
      "grey",
      "white"
    ]
  @code2color  %{
      "black" =>0,
      "brown" =>1,
      "red"   =>2,
      "orange"=>3,
      "yellow"=>4,
      "green" =>5,
      "blue"  =>6,
      "violet"=>7,
      "grey"  =>8,
      "white" =>9
  }

  @spec colors() :: list(String.t())
  def colors do
    @name_colors
  end

  @spec code(String.t()) :: integer()
  def code(color) do
    @code2color[color]
  end

end
